<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>买反可承受点数计算器</title>
    <script src="/js/jquery-3.3.1.min.js"></script>
    <style>
        input,button,span{
            float:right;
        }
        section{
            width: 300px;
        }
    </style>
</head>
<body>

<section>

    <div>余额<input id="amount" autocomplete="off" value="10000"/></div>
    <div>手数<input id="num" autocomplete="off" value="1"/></div>
    <div>每手保证金<input id="bail" autocomplete="off" value="1000"/></div>
    <div>当前获利<input id="get" autocomplete="off"/></div>
    <div>净值<span id="real_left"/></div>
    <div>已用预付款<span id="used"/></div>
    <div>可用预付款<span id="usable"/></div>
    <div>预付款比例<span id="scale"/></div>

    <div>进入点<input id="enter" autocomplete="off"/></div>
    <div>类型<input id="type" autocomplete="off" value="1"/>1买涨 2买跌</div>
    <div>当前点<input id="curr" autocomplete="off"/></div>
    <div>点差<span id="diff"/></div>
    <div>可承受亏损点数<span id="point"/></div>

    <div><button id="calc">计算</button></div>

</section>

<script>

    $('#calc').click(function(){

        var amount = parseFloat($('#amount').val());
        var num = parseFloat($('#num').val());
        var bail = parseFloat($('#bail').val());
        var get = parseFloat($('#get').val());

        var real_left = amount+get; //余额 + 当前获利
        $('#real_left').text(real_left);

        var used = num*bail;//手数 * 每手保证金1000
        $('#used').text(used);

        var usable = real_left-used;//净值 - 已用预付款
        $('#usable').text(usable);

        var scale = real_left/used*100;// 净值 / 已用预付款 * 100 %
        $('#scale').text(scale+'%');

        var enter = parseFloat($('#enter').val());//10
        var type = $('#type').val();//
        var curr = parseFloat($('#curr').val());//11 9
        var diff;
        if(type == '1'){
            diff = enter-curr;//买涨，结果跌了
        }else{
            diff = curr-enter;//买跌，结果涨了
        }
        $('#diff').text(diff);
        //最多可承受点数,
        var point = parseFloat($('#curr').val());


    })

</script>
</body>
</html>